/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gagnatech.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Dimitri
 */
@Entity
@Table(name = "author")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Author.findAll", query = "SELECT a FROM Author a"),
    @NamedQuery(name = "Author.findByIdauthor", query = "SELECT a FROM Author a WHERE a.idauthor = :idauthor"),
    @NamedQuery(name = "Author.findByName", query = "SELECT a FROM Author a WHERE a.name = :name"),
    @NamedQuery(name = "Author.findByBiography", query = "SELECT a FROM Author a WHERE a.biography = :biography")})
public class Author implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "IDAUTHOR")
    private Integer idauthor;
    @Size(max = 255)
    @Column(name = "NAME")
    private String name;
    @Size(max = 255)
    @Column(name = "BIOGRAPHY")
    private String biography;
    @OneToMany(mappedBy = "idAuthor")
    private List<Media> mediaList;

    public Author() {
    }

    public Author(Integer idauthor) {
        this.idauthor = idauthor;
    }

    public Integer getIdauthor() {
        return idauthor;
    }

    public void setIdauthor(Integer idauthor) {
        this.idauthor = idauthor;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getBiography() {
        return biography;
    }

    public void setBiography(String biography) {
        this.biography = biography;
    }

    @XmlTransient
    public List<Media> getMediaList() {
        return mediaList;
    }

    public void setMediaList(List<Media> mediaList) {
        this.mediaList = mediaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idauthor != null ? idauthor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Author)) {
            return false;
        }
        Author other = (Author) object;
        if ((this.idauthor == null && other.idauthor != null) || (this.idauthor != null && !this.idauthor.equals(other.idauthor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gagnatech.entity.Author[ idauthor=" + idauthor + " ]";
    }
    
}
